package com.example.demo.entity;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.RelationOneToOne;
import com.mybatisflex.annotation.Table;
import lombok.Data;

import java.util.Date;

/**
 * 用户实体类
 */
@Data
@Table("tb_user")
public class User {

    @Id(keyType = KeyType.Auto)
    private Long id;

    @Column("name")
    private String name;

    private Integer age;

    @Column("dept_id")
    private Long deptId;

    @Column("account_id")
    private Long accountId;

    private Integer status;

    @Column(value = "is_deleted", isLogicDelete = true)
    private Boolean isDeleted;

    @Column("create_time")
    private Date createTime;

    @Column("update_time")
    private Date updateTime;

    // 关联查询 - 账户信息
    @RelationOneToOne(selfField = "accountId", targetField = "id")
    private Account account;

    // 关联查询 - 部门信息
    @RelationOneToOne(selfField = "deptId", targetField = "id")
    private Department department;
}